﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Data;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Drawing;
using Crosland.Automotriz.Logic.Linq;
using Crosland.Automotriz.Core;
using Crosland.Automotriz.Logic;
using Crosland.Automotriz.Logic.Funciones;
using Crosland.Automotriz.Facade.Interface;
using Crosland.Automotriz.Facade.Facade;
using System.Text;
using System.Data.SqlClient;
using System.Configuration;
namespace Crosland.Automotriz.Web.Repuestos
{
    public partial class wFrmpronosticoImportacionNuevo : BaseForm
    {
        string idNegocio = ConfigurationManager.AppSettings["Negocio"];
        ActualizarPedidoLogic actualizapedido = new ActualizarPedidoLogic();
      iFacadePronosticoImportacion BL_PronosticoImportacion = new FacadePronosticoImportacion();


        protected override void Inicializar()
        {

            base.Inicializar();


            chkA.Checked = true;
            ChkB.Checked = true;
            chkC.Checked = true;


            cboPeriodo.Text = "180";
            cboStockDias.Text = "180";
            this.ListaMarcasActivos();
            cboMarca.SelectedIndex = 0;

        }

        void ListaMarcasActivos() {

            clsTD_MarcaLogic clstd_marca = new clsTD_MarcaLogic();
            cboMarca.DataSource = clstd_marca.ListarMarcaActivo();
            cboMarca.TextField = "DES_MARCA";
            cboMarca.ValueField = "ID_MARCA";
            cboMarca.DataBind();
        
        }




        protected void btnGenerar_Click(object sender, EventArgs e)
        {


        }

        protected void btnSalir_Click(object sender, ImageClickEventArgs e)
        {
            Response.Redirect("FrmPronosticoImportacion.aspx?id="+idNegocio);
        }

        protected void chkA_CheckedChanged(object sender, EventArgs e)
        {

        }







        protected void Timer1_Tick(object sender, EventArgs e)
        {



        }



        protected void btngene_Click(object sender, EventArgs e)
        {

            



                string var1 = "";
                if (chkA.Checked)
                {


                    var1 += "A";

                }
                else
                {

                    var1 = " ";
                }
                if (ChkB.Checked)
                {

                    var1 += "B";
                }
                else
                {

                    var1 = " ";

                }

                if (chkC.Checked)
                {

                    var1 += "C";


                }
                else
                {

                    var1 = " ";

                }
                if (chkSinRotacion.Checked)
                {


                    var1 += "N";
                }
                else
                {

                    var1 = " ";
                }


                if (chkDesContinuado.Checked)
                {

                    var1 += "O";
                }
                else
                {

                    var1 = " ";
                }

                try
                {





           

                    if (BL_PronosticoImportacion.generarImportacion(Convert.ToInt32(cboMarca.SelectedItem.Value), Convert.ToInt32(cboStockDias.Text), Convert.ToInt32(cboPeriodo.Text), var1))
                    {

                        string script = "ShowCreateAccountWindow8();";
                        ScriptManager.RegisterStartupScript(this, typeof(Page), "carga", script, true);
                       

                      

                    }
                    else
                    {
                      


                        lblmensaje.Text = Globales.msjSql;


                        string scripterror = "ShowCreateAccountWindow4();";
                        ScriptManager.RegisterStartupScript(this, typeof(Page), "carga", scripterror, true);

                    }



                }
              
                catch (Exception ex)
                {
                    lblmensaje.Text = ex.Message;
                 string scripterror = "ShowCreateAccountWindow4();";
                ScriptManager.RegisterStartupScript(this, typeof(Page), "carga", scripterror, true);
                }


               

                 
                }

        protected void btnsal_Click(object sender, EventArgs e)
        {
            Response.Redirect("~/Repuestos/wFrmPronosticoImportacion.aspx?id=" + idNegocio);
        }

               

            

        }
        
    

           
        

    
}